import React, { useState } from "react";
import { useData } from "./useData";

interface SearchResultsProps {
  query: string;
}
const SearchResults: React.FC<SearchResultsProps> = ({ query }) => {
  const [page, setPage] = useState("1");
  const params = new URLSearchParams({ query, page });
  const results = useData(`/api/search?${params}`);

  function handleNextPageClick() {
    setPage(page + 1);
  }

  return (
    <>
      <h1>{results}</h1>
      <button onClick={handleNextPageClick}>下一页</button>
    </>
  );
};
export default SearchResults;
